<html>
<head>  
    <style>@import "styles.css"</style>
    <script src="webrtcstreamer.js"></script>
    <script src="webrtcstreamer.json"></script>
    <script type="module" src="webrtc-streamer-element.js"></script>
</head>
<body>
  <webrtc-streamer id="stream"></webrtc-streamer>
  <footer id="footer"></footer>
  <script>
  customElements.whenDefined('webrtc-streamer').then(() => {
    var url = {video: webrtcConfig.defaultvideostream};  
    var options = webrtcConfig.options;
    if (typeof URLSearchParams != 'undefined') {
        var params = new URLSearchParams(location.search);
        if (params.has("video") || params.has("audio")) {
            url = { video:params.get("video"), audio:params.get("audio") };
        }
        if (params.has("options")) {
            options = params.get("options");
        }
    } 
    
    document.getElementById("stream").setAttribute('videostream', url.video);
    request("GET" , webrtcConfig.url + "/api/version").done( function (response) { 
        document.getElementById("footer").innerHTML = "<p><a href='https://github.com/mpromonet/webrtc-streamer'>WebRTC-Streamer</a> " + JSON.parse(response.body).split(" ")[0] + "</p>";			
    });	
  });
  </script>
</body>
</html>

